//
//  StatusCellBottomView.swift
//  Sina
//
//  Created by 王杰 on 15/11/17.
//  Copyright © 2015年 王杰. All rights reserved.
//

import UIKit
import SnapKit
class StatusCellBottomView: UIView {
    
    @objc private func retweetedBtnDidClcik() {
    
    let temp = TempViewController()
    
    retweenBtn.NavController()?.pushViewController(temp, animated: true)
    }

    //设置frame
    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = UIColor(white: 0.98, alpha: 1)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //设置UI
    
    private func setupUI() {
        
        addSubview(retweenBtn)
        addSubview(composeBtn)
        addSubview(likeBtn)
        let w : CGFloat = 2
        let scale = 0.4
        retweenBtn.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(snp_top)
            make.left.equalTo(snp_left)
            make.height.equalTo(snp_height)
        }
        let sepView1 = sepView()
        addSubview(sepView1)
        sepView1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweenBtn.snp_right)
            make.width.equalTo(w)
            make.centerY.equalTo(self.snp_centerY)
            make.height.equalTo(retweenBtn.snp_height).multipliedBy(scale)
        }
        composeBtn.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(snp_top)
            make.left.equalTo(sepView1.snp_right)
            make.width.equalTo(retweenBtn.snp_width)
            make.height.equalTo(snp_height)
        }
        let sepView2 = sepView()
        addSubview(sepView2)
        sepView2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(composeBtn.snp_right)
            make.width.equalTo(w)
            make.height.equalTo(retweenBtn.snp_height).multipliedBy(scale)
            make.centerY.equalTo(self.snp_centerY)
        }
        likeBtn.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(snp_top)
            make.width.equalTo(retweenBtn.snp_width)
            make.left.equalTo(composeBtn.snp_right)
            make.height.equalTo(snp_height)
            make.right.equalTo(snp_right)
        }
        
        //添加点击事件
        retweenBtn.addTarget(self, action: "retweetedBtnDidClcik", forControlEvents: .TouchUpInside)

    }

    //创建一个分割线
    
    private func sepView()->UIView {
        let vi = UIView()
        vi.backgroundColor = UIColor.greenColor()
        return vi
    }
    //懒加载控件
    private lazy var retweenBtn: UIButton = UIButton(title: "转发", backImage: nil, color: UIColor.darkGrayColor(), image: "timeline_icon_retweet", size: 10)
    private lazy var composeBtn: UIButton = UIButton(title: "评论", backImage: nil, color: UIColor.darkGrayColor(), image: "timeline_icon_comment", size: 10)
    private lazy var likeBtn: UIButton = UIButton(title: "赞", backImage: nil, color: UIColor.darkGrayColor(), image: "timeline_icon_unlike", size: 10)
}
